﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CommonLibrary;
using CommonLibrary.BLL;
using CommonLibrary.Model;
using Microsoft.Win32;
using Yipusoft.SystemSet;

namespace SmsSeries
{
    public partial class frmTemplate : Form
    {
        #region 变量

        /// <summary>
        /// 是否是更新
        /// </summary>
        private bool isUpdate;

        #endregion

        #region 属性

        /// <summary>
        /// 是否是更新
        /// </summary>
        public bool IsUpdate
        {
            get
            {
                return isUpdate;
            }
            set
            {
                isUpdate = value;

                if(value)
                {
                    btnOKLinkman.Text = "修改";
                }
                else
                {
                    btnOKLinkman.Text = "添加";
                    tbTemplateName.Text = "";
                    tbTemplateContent.Text = "";
                }
            }
        }

        /// <summary>
        /// 模板名称
        /// </summary>
        public string TemplateName
        {
            set
            {
                tbTemplateName.Text = value;
            }
        }

        /// <summary>
        /// 模板内容
        /// </summary>
        public string TemplateContent
        {
            set
            {
                tbTemplateContent.Text = value;
            }
        }

        #endregion

        #region 控件事件

        //联系人 添加修改
        private void btnOKLinkman_Click(object sender, EventArgs e)
        {
            AddOrUpdateTemplate();
        }

        //取消
        private void btnCancelLinkman_Click(object sender, EventArgs e)
        {
            Close();
        }

        /// <summary>
        /// 加载控件
        /// </summary>
        public void initializeComponent()
        {
            InitializeComponent();
        }

        #endregion

        #region 自定义事件

        /// <summary>
        /// 添加或修改短信模板
        /// </summary>
        public event EventHandler<Data.TwoEventArgs> AddOrUpdateTemplateEvent;

        /// <summary>
        /// 添加或修改短信模板
        /// </summary>
        private void AddOrUpdateTemplate()
        {
            if (null != AddOrUpdateTemplateEvent)
            {
                Data.TwoEventArgs args = new Data.TwoEventArgs();
                args.Obj1 = tbTemplateName.Text;
                args.Obj2 = tbTemplateContent.Text;
                AddOrUpdateTemplateEvent(this, args);
            }
        }

        #endregion 自定义事件
    }
}
